package com.ny.service.impl;

import com.ny.dao.StudentDao;
import com.ny.dao.impl.StudentDaoImpl;
import com.ny.entity.Stud;
import com.ny.service.StudentService;

import java.sql.SQLException;
import java.util.List;

public class StudentServiceImpl implements StudentService {
    private StudentDao studentDao = new StudentDaoImpl();


    public StudentServiceImpl() throws SQLException, ClassNotFoundException {
    }

    @Override
    public int addStu(Stud stud) throws SQLException, ClassNotFoundException {

        studentDao = new StudentDaoImpl();
        return studentDao.addStu(stud);
    }

    @Override
    public Stud log(String name, String pwd) throws SQLException {
        return studentDao.log(name, pwd);
    }

    @Override
    public Stud changePwd(String name, String pwd) throws SQLException, ClassNotFoundException {

         return studentDao.changePwd(name, pwd);
    }

    @Override
    public Stud deleteStu(String name, String pwd) throws SQLException {
        return studentDao.deleteStu(name, pwd);
    }

    @Override
    public Stud changePho(String name, String phone) throws SQLException, ClassNotFoundException {
        studentDao = new StudentDaoImpl();
        return studentDao.changePho(name, phone);
    }

    public List<Stud> findAll() throws SQLException, ClassNotFoundException {
        studentDao = new StudentDaoImpl();
        return studentDao.findAll();
    }
}
